<!DOCTYPE html>
<html xmlns:th="http://www.springframework.org/schema/jdbc">
	<head th:replace="admin/_fragments :: head(~{::title})">
	    <meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
	    <title>角色更改/新增列表</title>
		<link rel="stylesheet" href="../../static/css/bootstrap.min.css" />
		<link rel="stylesheet" href="../../static/lib/bootstrapValidator/css/bootstrapValidator.min.css"/>
	</head>
	<body>
	<!--导航栏-->
	<div  th:replace="admin/_fragments :: nav">
		<nav class="navbar navbar-inverse navbar-static-top" role="navagation">
			<div class="container">
				<!-- logo -->
				<div class="navbar-header">
					<a href="#" class="navbar-brand">管理后台</a>
				</div>
				<div id="navbar" class="collapse navbar-collapse">
					<ul class="nav navbar-nav">
						<li ><a href="#" th:href="admin"><i class="glyphicon glyphicon-th"></i>&nbsp;角色管理</a></li>
					</ul>
				</div>
			</div>
		</nav>
	</div>

		<!-- 中间内容-->
	<div class="container" style="margin-top: 200px;width: 40%">
		<form action="/admin/roles/save" th:action="@{/admin/roles/save}" method="post">
			<div class="row form-group">
				<div class="col-xs-6  form-group">
					<label for="rname">角色名称</label>
					<input type="text" id="rname" name="rname" class="form-control" th:value="${role.rname}"/>
				</div>
				<div class="col-xs-6 form-group">
					<label for="sortnum">排序字段</label>
					<input type="text" id="sortnum" name="sortnum" class="form-control" th:value="${role.sortnum}">
				</div>
			</div>
			<div class="form-group">
				<label for="remark">角色描述</label>
				<input type="text" id="remark" name="remark" class="form-control" th:value="${role.remark}" placeholder="15字以内"/>
			</div>
			<div class="form-group">
				<label>发布状态</label>
				<input type="radio" name="status" value="1" checked="checked" th:checked="${role.status != '0'}"/> 发布 <input type="radio" name="status" value="0" th:checked="${role.status == '0'}"/> 暂不发布
			</div>
			<div class="text-center" style="margin-top: 3.125rem;">
				<button type="submit" class="btn btn-primary" style="width: 100%;">提交</button>
			</div>
		</form>
	</div>
	<!--/*/<th:block th:replace="admin/_fragments :: script">/*/-->
	<script type="text/javascript" src="../../static/jquery/jquery-3.4.1.min.js"></script>
	<script type="text/javascript" src="../../static/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../../static/lib/bootstrapValidator/js/bootstrapValidator.min.js"></script>
	<!--/*/</th:block>/*/-->
	<script>
		$(function () {
			/*表单验证的初始化*/
			$('form').bootstrapValidator({
				fields: {
					rname: {
						validators: {
							notEmpty: {
								message: '角色名不能为空'
							}
						}
					},
					sortnum: {
						validators: {
							notEmpty: {
								message: '排序字段不能为空'
							}
						}
					},
					remark: {
						validators: {
							notEmpty: {
								message: '角色描述不能为空'
							}
						}
					}
				}
			});
		});

		// 提交时验证
		$('form').submit(function () {
			var bootstrapValidator = $('form').data('bootstrapValidator');
			// 提交时验证
			bootstrapValidator.validate();
			if (bootstrapValidator.isValid()) {
				return true;
			} else {
				return false;
			}
		});
	</script>
	</body>
</html>
